/*
 * @Author       : tongzonghua
 * @Date         : 2020-10-27 14:53:49
 * @LastEditors  : tongzonghua
 * @LastEditTime : 2020-10-27 15:00:23
 * @Email        : tongzonghua@360.cn
 * @Description  : 
 * @FilePath     : /cli/aframe-boilerplate/components/cursorListener.js
 */
AFRAME.registerComponent('cursor-listener', {

  init: function () {

    var COLORS = ['red', 'green', 'blue'];

    this.el.addEventListener('click', function (evt) {

      var randomIndex = Math.floor(Math.random() * COLORS.length);

      this.setAttribute('material', 'color', COLORS[randomIndex]);

      console.log('I was clicked at: ', evt.detail.intersection.point);

    });

  }

});